﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Microsoft.Windows.Controls;

namespace HBCode.Converters
{
    public class WindowsStateConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool? isVisible = value as bool?;
            if (!isVisible.HasValue || !isVisible.Value)
            {
                return WindowState.Closed;
            }
            else
            {
                return WindowState.Open;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            WindowState windowState = (WindowState)value;
            if (windowState == WindowState.Closed)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}
